(function (doc,tools,compute) {
    const result = doc.querySelector('.result');
    const inputs = doc.querySelectorAll('input');
    const btnGroup = doc.querySelector('.btn-group');
    // 模块初始化函数
    const init = function () {
        bindEvent();
    }
    // 绑定事件处理函数
    function bindEvent() {
        btnGroup.addEventListener('click', btnClick, false);
    }
    function btnClick(ev) {
        tagName = tools.getTarget(ev).tagName.toLowerCase();
        if (tagName === "button") {
            const method = tools.getTarget(ev).getAttribute('data-method');
            const fval = tools.toNumber(inputs[0].value);
            const sval = tools.toNumber(inputs[1].value);
            renderResult(compute[method](fval, sval));
        }
    }
    function renderResult(res){
        result.innerText = res;
    }
    
    init();
})(document,tools,compute)